package com.wicket.okrpbff.biz.service.impl;

import cn.hutool.core.bean.BeanUtil;
import com.wicket.okrpbff.biz.service.UnstructuredDataService;
import com.wicket.okrpbff.biz.service.dto.req.*;
import com.wicket.okrpbff.biz.service.dto.res.*;
import com.wicket.okrpbff.common.ro.OkrResult;
import com.wicket.okrpbff.common.ro.OkrResult;
import com.wicket.okrpbff.common.util.CommonFunctionHelper;
import com.wicket.okrpbff.common.util.RedisUtil;
import javax.annotation.Resource;
import org.apache.skywalking.apm.toolkit.trace.Tag;
import org.apache.skywalking.apm.toolkit.trace.Tags;
import org.apache.skywalking.apm.toolkit.trace.Trace;
import org.springframework.stereotype.Service;
import com.wicket.okrcomponent.integration.FwCompUnstructuredDataClient;
import com.wicket.okrcomponent.integration.dto.QueryDocumentListComRespDto;
import com.wicket.okrcomponent.integration.dto.QueryDocumentListComReqDto;
import com.wicket.okrcomponent.integration.dto.ImplementUnstructuredRelationshipCompDocNameComRespDto;
import com.wicket.okrcomponent.integration.dto.ImplementUnstructuredRelationshipCompDocNameComReqDto;
import java.util.stream.Collectors;
import cn.hutool.core.collection.CollectionUtil;
import com.wicket.okrpbff.common.exception.Assert;

/**
 * @author ：
 * @date ：
 *
 *
 * @version 1.0
 */
@Service
public class UnstructuredDataServiceImpl implements UnstructuredDataService {

  @Resource
  private RedisUtil redisUtil;
@Resource
  FwCompUnstructuredDataClient fwCompUnstructuredDataClient;
/**
   * B2执行文档关系补偿文档名称（运维接口）[10055]
   * gen by moon at 8/6/2024, 7:55:36 PM
   */
    @Trace(operationName = "B2执行文档关系补偿文档名称（运维接口）")
    @Tags({@Tag(key = "参数",value = "arg[0]"),
            @Tag(key = "返回值",value = "returnedObj")})
  @Override
  public BffImplementUnstructuredRelationshipCompDocNameRespDto implementUnstructuredRelationshipCompDocName(BffImplementUnstructuredRelationshipCompDocNameReqDto reqDto){
      
       
       //virtualUsage D2查询文档列表(公共)  71990
      QueryDocumentListComRespDto queryDocumentListComRespDto = null;
    QueryDocumentListComReqDto queryDocumentListComReqDto=new QueryDocumentListComReqDto();
  if(reqDto!=null){
      queryDocumentListComReqDto.setSpaceId(reqDto.getSpaceId());//SimpleFieldAssign//sourceId:1956422_1_71990
    }
  
    /*D2查询文档列表(公共)[10056]   */
    Assert.isNull(queryDocumentListComReqDto.getSpaceId(),"B2执行文档关系补偿文档名称（运维接口）-D2查询文档列表(公共)-创建于空间ID不能为空",false);
      queryDocumentListComRespDto = fwCompUnstructuredDataClient.queryDocumentListCom(queryDocumentListComReqDto).getData()/*vcase invoke 跨dubbo调用;*/;
      
      
      
if((queryDocumentListComRespDto!= null&&  queryDocumentListComRespDto.getDocumentList() !=null && queryDocumentListComRespDto.getDocumentList().size()>0)) {
        //if(D2查询空间下所有文档列表(公共).文档列表数据集条数 大于 0)  71991
        
ImplementUnstructuredRelationshipCompDocNameComRespDto implementUnstructuredRelationshipCompDocNameComRespDto = null;
    if(queryDocumentListComRespDto !=null){
          ImplementUnstructuredRelationshipCompDocNameComReqDto implementUnstructuredRelationshipCompDocNameComReqDto=new ImplementUnstructuredRelationshipCompDocNameComReqDto();
  if(queryDocumentListComRespDto!= null&&  queryDocumentListComRespDto.getDocumentList() !=null&& !CollectionUtil.isEmpty(queryDocumentListComRespDto.getDocumentList())){
      implementUnstructuredRelationshipCompDocNameComReqDto.setDocumentList(queryDocumentListComRespDto.getDocumentList().stream().map(item->item.getUnstructuredDataId())
        .collect(Collectors.toList()));/*list-to-strings*///sourceId:1956424_1_71992
    }
if(reqDto!=null){
      implementUnstructuredRelationshipCompDocNameComReqDto.setSpaceId(reqDto.getSpaceId());//SimpleFieldAssign//sourceId:1956425_1_71992
    }
  
    /*D2执行文档关系补偿文档名称(公共)[10053]   */
    Assert.isNull(implementUnstructuredRelationshipCompDocNameComReqDto.getSpaceId(),"B2执行文档关系补偿文档名称（运维接口）-D2执行文档关系补偿文档名称(公共)-创建于空间ID不能为空",false);
      implementUnstructuredRelationshipCompDocNameComRespDto = fwCompUnstructuredDataClient.implementUnstructuredRelationshipCompDocNameCom(implementUnstructuredRelationshipCompDocNameComReqDto).getData()/*vcase invoke 跨dubbo调用;*/;
      
      
      
           }
      }
BffImplementUnstructuredRelationshipCompDocNameRespDto retData = new BffImplementUnstructuredRelationshipCompDocNameRespDto();
  
  

  
  
return retData;
  }
  //
}
